package com.hmall.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hmall.common.utils.UserContext;
import com.hmall.user.domain.dto.AddressDTO;
import com.hmall.user.domain.po.Address;
import com.hmall.user.mapper.AddressMapper;
import com.hmall.user.service.IAddressService;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 虎哥
 * @since 2023-05-05
 */
@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements IAddressService {

    @Override
    public void addAddress(AddressDTO addressDTO) {
        Address address = new Address();
        address.setUserId(UserContext.getUser());
        address.setProvince(addressDTO.getProvince());
        address.setCity(addressDTO.getCity());
        address.setTown(addressDTO.getTown());
        address.setMobile(addressDTO.getMobile());
        address.setStreet(addressDTO.getStreet());
        address.setContact(addressDTO.getContact());
        address.setIsDefault(addressDTO.getIsDefault());
        address.setNotes(addressDTO.getNotes());
        save(address);
    }

}
